package Demo03.Demo03;

import java.util.LinkedList;
import java.util.Objects;
import java.util.Scanner;

public class MyQueue {
    LinkedList<Object> link = new LinkedList<>();
    Scanner sc = new Scanner(System.in);
    boolean fale =true;
    Object temp = null;
    /*
        wtite()方法，写一个方法让用户输入

     */
    public void  wtite(){
        do {
            System.out.println("请输入队列的值（按0退出）");
            temp = sc.next();
            if (temp.equals("0")){
                fale = false;
            }else {
                //调用进入队列的方法
                setQueue(temp);
            }
        }while (fale);
    }
    //进入队列集合
    private void setQueue(Object temp) {
        link.addLast(temp);
    }
    //输入队列
    public Object getQueue(){
        Object temp = null;
        if (!link.isEmpty()){
            temp = link.getFirst();
            link.removeFirst();
        }
        return temp;
    }
}
